package com.googlecode.jlogindexer.utils;

import java.io.InputStream;
import java.util.Properties;


public class PropertyUtil{
	
	private static final String FileName = "jlogalizerweb.properties";
	
	private Properties jlogalizerWebProperties; 
	private static PropertyUtil singleton;
	
	private PropertyUtil (String fileName){
		System.out.println("Enter PropertyUtil - Properties load ");
		if (jlogalizerWebProperties==null) { 
			
			jlogalizerWebProperties = new Properties();
			InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
			
			try{
				jlogalizerWebProperties.load(inputStream);
			}
			catch(Exception e){
				e.printStackTrace();
				throw new RuntimeException("Can't load property file - jlogalizerweb.properties from class path");
			}
			System.out.println("Exit PropertyUtil - Properties load ");
			
		}
	}
	
	public static PropertyUtil getInstance() {
		if (singleton == null){
			singleton = new PropertyUtil(FileName);
		}
		return singleton;
	}
	
	public String getValue(String key) {
			return jlogalizerWebProperties.getProperty(key);
	}
	
}